﻿#include "FITKAcousticsSpectraMgrAdaptor.h"
#include "FITKAcousticsHDF5Writer.h"
#include "FITKAcousticsHDF5Reader.h"
#include "FITK_Interface/FITKInterfaceIO/FITKHDF5FileTool.h"

#include "FITK_Component/FITKAcousticsPhysics/FITKPhyscisPropertyBeam.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraDampingLossFactor.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraAlgorithm.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraAbstractModalDensity.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraAbstractAcceleration.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraAbstractPower.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraAbstractTransmission.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraDampingLossFactor.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraAbsorptionCoefficient.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraModalDensity.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraWavenumber.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraCouplingLossFactor.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraTransmissionLoss.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraInsertionLoss.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraShearModulus.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraVelocity.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraAngularVelocity.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraAcceleration.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraForce.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraMoment.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraPressure.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraEnergy.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraPower.h"


#include <H5Cpp.h>
bool IO::FITKAcousticsSpectraMgrAdaptor::adaptR()
{
    Acoustics::FITKAcousticsSpectraManager* SpectraManager =
        dynamic_cast<Acoustics::FITKAcousticsSpectraManager*>(_dataObj);
    if (SpectraManager == nullptr || _reader == nullptr) return false;
    m_toolp = _reader->getHDF5FileTool();//初始化工具

    std::tuple<bool, H5::Group>Ret = m_toolp->openGp("Spectra");//打开频谱组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group SpectraGroup = std::get<1>(Ret);

    bool DampingRet = this->readDamping(SpectraGroup, SpectraManager);
    bool AbsorptionCoefficientRet = this->readAbsorptionCoefficient(SpectraGroup, SpectraManager);
    bool ModalDensityRet = this->readModalDensity(SpectraGroup, SpectraManager);
    bool WavenumbersRet = this->readWavenumbers(SpectraGroup, SpectraManager);
    bool CouplingLossFactorRet = this->readCouplingLossFactor(SpectraGroup, SpectraManager);
    bool TransmissionLossRet = this->readTransmissionLoss(SpectraGroup, SpectraManager);
    bool InsertionLossRet = this->readInsertionLoss(SpectraGroup, SpectraManager);
    bool ShearModulusRet = this->readShearModulus(SpectraGroup, SpectraManager);
    bool VelocitysRet = this->readVelocitys(SpectraGroup, SpectraManager);
    bool AnlrVelocitysRet = this->readAnlrVelocitys(SpectraGroup, SpectraManager);
    bool AccelerationsRet = this->readAccelerations(SpectraGroup, SpectraManager);
    bool ForcesRet = this->readForces(SpectraGroup, SpectraManager);
    bool MomentsRet = this->readMoments(SpectraGroup, SpectraManager);
    bool PressuresRet = this->readPressures(SpectraGroup, SpectraManager);
    bool EnergysRet = this->readEnergys(SpectraGroup, SpectraManager);
    bool PowersRet = this->readPowers(SpectraGroup, SpectraManager);
    return DampingRet && AbsorptionCoefficientRet&&ModalDensityRet&&WavenumbersRet&&CouplingLossFactorRet&&TransmissionLossRet &&InsertionLossRet
        &&ShearModulusRet && VelocitysRet && AnlrVelocitysRet &&AccelerationsRet &&ForcesRet&&MomentsRet &&PressuresRet &&EnergysRet&&PowersRet;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::adaptW()
{
    Acoustics::FITKAcousticsSpectraManager* SpectraManager =
        dynamic_cast<Acoustics::FITKAcousticsSpectraManager*>(_dataObj);
    if (SpectraManager == nullptr || _writer == nullptr) return false;
    m_toolp = _writer->getHDF5FileTool();//初始化工具

    //获取损耗因子谱
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Dampings = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Damping);

    //获取Absorption
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Absorptions = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Absorption);

    //获取模态密度
    QList<Acoustics::FITKAcousticsAbstractSpectra*> ModalDensitys = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::ModalDensity);

    //获取波数谱
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Wavenumbers = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Wavenumber);

    //耦合损耗因子谱
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Couplings = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Coupling);

    //传递损失
    QList<Acoustics::FITKAcousticsAbstractSpectra*> TransmissionLoss = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::TransmissionLoss);

    //插入损失
    QList<Acoustics::FITKAcousticsAbstractSpectra*> InsertionLosss = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::InsertionLoss);

    //剪切模量
    QList<Acoustics::FITKAcousticsAbstractSpectra*> ShearModuluss = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::ShearModulus);

    //速度
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Velocitys = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Velocity);

    //角速度
    QList<Acoustics::FITKAcousticsAbstractSpectra*> AnlrVelocitys = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::AnlrVelocity);

    //加速度
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Accelerations = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Acceleration);

    //力
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Forces = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Force);

    //力矩
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Moments = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Moment);

    //声压
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Pressures = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Pressure);

    //能量
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Energys = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Energy);

    //功率
    QList<Acoustics::FITKAcousticsAbstractSpectra*> Powers = SpectraManager->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Power);



    std::tuple<bool, H5::Group> Ret = m_toolp->createGp("Spectra");     //创建频谱组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group SpectraGroup = std::get<1>(Ret);
    bool DampingRet = this->writeDamping(SpectraGroup, Dampings);
    bool AbsorptionCoefficientRet = this->writeAbsorptionCoefficient(SpectraGroup, Absorptions);
    bool ModalDensityRet = this->writeModalDensity(SpectraGroup, ModalDensitys);
    bool WavenumbersRet = this->writeWavenumbers(SpectraGroup, Wavenumbers);
    bool CouplingsRet = this->writeCouplingLossFactor(SpectraGroup, Couplings);
    bool TransmissionLossRet = this->writeTransmissionLoss(SpectraGroup, TransmissionLoss);
    bool InsertionLossRet = this->writeInsertionLoss(SpectraGroup, InsertionLosss);
    bool ShearModulussRet = this->writeShearModulus(SpectraGroup, ShearModuluss);
    bool VelocitysRet = this->writeVelocitys(SpectraGroup, Velocitys);
    bool AnlrVelocitysRet = this->writeAnlrVelocitys(SpectraGroup, AnlrVelocitys);
    bool AccelerationsRet = this->writeAccelerations(SpectraGroup, Accelerations);
    bool ForcesRet = this->writeForces(SpectraGroup, Forces);
    bool MomentsRet = this->writeMoments(SpectraGroup, Moments);
    bool PressuresRet = this->writePressures(SpectraGroup, Pressures);
    bool EnergysRet = this->writeEnergys(SpectraGroup, Energys);
    bool PowersRet = this->writePowers(SpectraGroup, Powers);
    return DampingRet && AbsorptionCoefficientRet && ModalDensityRet && WavenumbersRet && CouplingsRet &&TransmissionLossRet
        && InsertionLossRet && ShearModulussRet && VelocitysRet &&AnlrVelocitysRet && AccelerationsRet &&ForcesRet&&MomentsRet&&PressuresRet&&EnergysRet&&PowersRet;
}

QString IO::FITKAcousticsSpectraMgrAdaptor::RestoreStr(std::string data)
{
    QString CheckStr = QString::fromStdString(data);
    m_toolp->RestoreString(CheckStr);//检查是否原来有字符/，有则转换
    return CheckStr;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readDamping(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager==nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "Dampings");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "DampingsCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);

        Acoustics::FITKSpectraDampingLossFactor*newObjData = new Acoustics::FITKSpectraDampingLossFactor();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }
        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);


        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeDamping(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> Dampings)
{

    //创建的HDF5目录结构
    const char *Path = "Spectra/Dampings";

    int count = Dampings.size();//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "Dampings", "DampingsCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, Dampings);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraDampingLossFactor* ObjP = dynamic_cast<Acoustics::FITKSpectraDampingLossFactor*>(Dampings.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        //检查字符串输入是否有特殊字符
        m_toolp->CheckString(Name);


        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        std::vector<bool>writeResultBools;//存储此次写入时返回成功与否数据
        //将数据写入到具体属性中
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeAbsorptionCoefficient(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> AbsorptionCoefficients)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/AbsorptionCoefficient";
    int count = AbsorptionCoefficients.size();;//获取数据行数

   //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "AbsorptionCoefficient", "AbsorptionCoefficientCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, AbsorptionCoefficients);//写基本数据 --频谱数据抽象对象 数据

    //写子类数据
    for (int i = 0; i < count; ++i)
    {

        Acoustics::FITKSpectraAbsorptionCoefficient* ObjP = dynamic_cast<Acoustics::FITKSpectraAbsorptionCoefficient*>(AbsorptionCoefficients.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);


        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);

        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet) == false)
        {
            return false;
        }
    }

    return false;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readAbsorptionCoefficient(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager==nullptr)
    {
        return false;
    }

    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "AbsorptionCoefficient");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "AbsorptionCoefficientCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraAbsorptionCoefficient*newObjData = new Acoustics::FITKSpectraAbsorptionCoefficient();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);


        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeModalDensity(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> ModalDensitys)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/ModalDensityss";

    int count = ModalDensitys.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "ModalDensityss", "ModalDensityssCount", count);


    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);


    this->writeBaseData(thisGroup, ModalDensitys);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraModalDensity* ObjP = dynamic_cast<Acoustics::FITKSpectraModalDensity*>(ModalDensitys.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readModalDensity(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager==nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "ModalDensityss");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "ModalDensityssCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraModalDensity*newObjData = new Acoustics::FITKSpectraModalDensity();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeWavenumbers(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> Wavenumberss)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/Wavenumbers";

    int count = Wavenumberss.size();//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "Wavenumbers", "WavenumbersCount", count);


    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);


    this->writeBaseData(thisGroup, Wavenumberss);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraWavenumber* ObjP = dynamic_cast<Acoustics::FITKSpectraWavenumber*>(Wavenumberss.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readWavenumbers(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager==nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "Wavenumbers");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "WavenumbersCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraWavenumber*newObjData = new Acoustics::FITKSpectraWavenumber();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeCouplingLossFactor(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> CouplingLossFactors)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/CouplingLossFactors";

    int count = CouplingLossFactors.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "CouplingLossFactors", "CouplingLossFactorsCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, CouplingLossFactors);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraCouplingLossFactor* ObjP = dynamic_cast<Acoustics::FITKSpectraCouplingLossFactor*>(CouplingLossFactors.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readCouplingLossFactor(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager==nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "CouplingLossFactors");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "CouplingLossFactorsCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraCouplingLossFactor*newObjData = new Acoustics::FITKSpectraCouplingLossFactor();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeTransmissionLoss(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> TransmissionLoss)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/TransmissionLoss";

    int count = TransmissionLoss.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "TransmissionLoss", "TransmissionLossCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, TransmissionLoss);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraTransmissionLoss* ObjP = dynamic_cast<Acoustics::FITKSpectraTransmissionLoss*>(TransmissionLoss.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readTransmissionLoss(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "TransmissionLoss");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "TransmissionLossCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraTransmissionLoss*newObjData = new Acoustics::FITKSpectraTransmissionLoss();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}


bool IO::FITKAcousticsSpectraMgrAdaptor::writeInsertionLoss(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> InsertionLoss)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/InsertionLoss";

    int count = InsertionLoss.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "InsertionLoss", "InsertionLossCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, InsertionLoss);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraInsertionLoss* ObjP = dynamic_cast<Acoustics::FITKSpectraInsertionLoss*>(InsertionLoss.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readInsertionLoss(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "InsertionLoss");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "InsertionLossCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraInsertionLoss*newObjData = new Acoustics::FITKSpectraInsertionLoss();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeShearModulus(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> ShearModulus)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/ShearModulus";

    int count = ShearModulus.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "ShearModulus", "ShearModulusCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, ShearModulus);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraShearModulus* ObjP = dynamic_cast<Acoustics::FITKSpectraShearModulus*>(ShearModulus.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readShearModulus(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "ShearModulus");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "ShearModulusCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraShearModulus*newObjData = new Acoustics::FITKSpectraShearModulus();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeVelocitys(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> Velocitys)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/Velocitys";

    int count = Velocitys.size();//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "Velocitys", "VelocitysCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, Velocitys);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraVelocity* ObjP = dynamic_cast<Acoustics::FITKSpectraVelocity*>(Velocitys.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();
        int FromType = ObjP->getFormCalcType();//Form类型

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool FromTypeRet = m_toolp->writeGroupAttrInt(subGroup, "FromType", FromType);
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet&&FromTypeRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readVelocitys(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "Velocitys");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "VelocitysCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        int FromType = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "FromType", &FromType);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraVelocity*newObjData = new Acoustics::FITKSpectraVelocity();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setFormCalcType(FromType);//设置form类型
        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeAnlrVelocitys(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> AnlrVelocitys)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/AnlrVelocitys";

    int count = AnlrVelocitys.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "AnlrVelocitys", "AnlrVelocitysCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, AnlrVelocitys);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraAngularVelocity* ObjP = dynamic_cast<Acoustics::FITKSpectraAngularVelocity*>(AnlrVelocitys.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();
        int FromType = ObjP->getFormCalcType();//Form类型

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool FromTypeRet = m_toolp->writeGroupAttrInt(subGroup, "FromType", FromType);
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet&&FromTypeRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readAnlrVelocitys(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "AnlrVelocitys");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "AnlrVelocitysCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        int FromType = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "FromType", &FromType);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraAngularVelocity*newObjData = new Acoustics::FITKSpectraAngularVelocity();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setFormCalcType(FromType);//设置form类型
        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeAccelerations(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> Accelerations)
{

    //创建的HDF5目录结构
    const char *Path = "Spectra/Accelerations";

    int count = Accelerations.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "Accelerations", "AccelerationsCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, Accelerations);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraAcceleration* ObjP = dynamic_cast<Acoustics::FITKSpectraAcceleration*>(Accelerations.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();
        int FromType = ObjP->getFormCalcType();//Form类型

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool FromTypeRet = m_toolp->writeGroupAttrInt(subGroup, "FromType", FromType);
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet&&FromTypeRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readAccelerations(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "Accelerations");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "AccelerationsCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        int FromType = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "FromType", &FromType);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraAcceleration*newObjData = new Acoustics::FITKSpectraAcceleration();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setFormCalcType(FromType);//设置form类型
        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeForces(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> Forces)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/Forces";

    int count = Forces.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "Forces", "ForcesCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, Forces);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraForce* ObjP = dynamic_cast<Acoustics::FITKSpectraForce*>(Forces.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();
        int FromType = ObjP->getFormCalcType();//Form类型

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool FromTypeRet = m_toolp->writeGroupAttrInt(subGroup, "FromType", FromType);
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet&&FromTypeRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readForces(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "Forces");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "ForcesCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        int FromType = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "FromType", &FromType);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraForce*newObjData = new Acoustics::FITKSpectraForce();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setFormCalcType(FromType);//设置form类型
        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}


bool IO::FITKAcousticsSpectraMgrAdaptor::writeMoments(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> Moments)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/Moments";

    int count = Moments.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "Moments", "MomentsCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, Moments);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraMoment* ObjP = dynamic_cast<Acoustics::FITKSpectraMoment*>(Moments.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();
        int FromType = ObjP->getFormCalcType();//Form类型

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool FromTypeRet = m_toolp->writeGroupAttrInt(subGroup, "FromType", FromType);
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet&&FromTypeRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readMoments(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "Moments");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "MomentsCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        int FromType = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "FromType", &FromType);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraMoment*newObjData = new Acoustics::FITKSpectraMoment();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setFormCalcType(FromType);//设置form类型
        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writePressures(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> Pressures)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/Pressures";

    int count = Pressures.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "Pressures", "PressuresCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, Pressures);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraPressure* ObjP = dynamic_cast<Acoustics::FITKSpectraPressure*>(Pressures.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();
        int FromType = ObjP->getFormCalcType();//Form类型

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool FromTypeRet = m_toolp->writeGroupAttrInt(subGroup, "FromType", FromType);
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet&&FromTypeRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readPressures(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "Pressures");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "PressuresCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        int FromType = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "FromType", &FromType);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraPressure*newObjData = new Acoustics::FITKSpectraPressure();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setFormCalcType(FromType);//设置form类型
        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writeEnergys(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> Energys)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/Energys";

    int count = Energys.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "Energys", "EnergysCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, Energys);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraEnergy* ObjP = dynamic_cast<Acoustics::FITKSpectraEnergy*>(Energys.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();
        int FromType = ObjP->getFormCalcType();//Form类型

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool FromTypeRet = m_toolp->writeGroupAttrInt(subGroup, "FromType", FromType);
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet&&FromTypeRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readEnergys(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "Energys");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "EnergysCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        int FromType = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "FromType", &FromType);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraEnergy*newObjData = new Acoustics::FITKSpectraEnergy();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setFormCalcType(FromType);//设置form类型
        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::writePowers(H5::Group & SpectrGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> Powers)
{
    //创建的HDF5目录结构
    const char *Path = "Spectra/Powers";

    int count = Powers.size();;//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(SpectrGroup, "Powers", "PowersCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    this->writeBaseData(thisGroup, Powers);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKSpectraPower* ObjP = dynamic_cast<Acoustics::FITKSpectraPower*>(Powers.at(i));
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //名称
        m_toolp->CheckString(Name);
        bool DBEnableState = ObjP->getDBEnableState();
        bool AWeightingEnableState = ObjP->getAWeightingEnableState();
        double DBUserCoefficient = ObjP->getDBUserCoefficient();
        int FromType = ObjP->getFormCalcType();//Form类型

        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, Name.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        bool FromTypeRet = m_toolp->writeGroupAttrInt(subGroup, "FromType", FromType);
        bool DBEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "DBEnableState", DBEnableState == true ? 1 : 0);
        bool AWeightingEnableStateRet = m_toolp->writeGroupAttrInt(subGroup, "AWeightingEnableState", AWeightingEnableState == true ? 1 : 0);
        bool DBUserCoefficientRet = m_toolp->writeGroupAttrDouble(subGroup, "DBUserCoefficient", DBUserCoefficient);
        if ((DBEnableStateRet&&AWeightingEnableStateRet&&DBUserCoefficientRet&&FromTypeRet) == false)
        {
            return false;
        }
    }
    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::readPowers(H5::Group & SpectraGroup, Acoustics::FITKAcousticsSpectraManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(SpectraGroup, "Powers");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisMaterialsGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisMaterialsGroup, "PowersCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);

    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
        std::string subGroupName = m_toolp->readGroupAttrName(thisMaterialsGroup, i);
        //打开子组
        std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisMaterialsGroup, subGroupName.data());
        if (std::get<0>(RetGroup) == false) { continue; }//打不开则退出此次
        H5::Group subGroup = std::get<1>(RetGroup);

        double StarFreq = 0.0;
        double EndFreq = 0.0;
        double BandWidth = 0.0;
        double DBUserCoefficient = 0.0;
        int ID = -1;
        int OctaveNum = -1;
        int DBEnableState = -1;
        int AWeightingEnableState = -1;
        int FromType = -1;
        std::string DomainTypeStr = "";//频率类型


        m_toolp->readGroupDouble(subGroup, "StarFreq", &StarFreq);
        m_toolp->readGroupDouble(subGroup, "EndFreq", &EndFreq);
        m_toolp->readGroupDouble(subGroup, "BandWidth", &BandWidth);
        m_toolp->readGroupDouble(subGroup, "DBUserCoefficient", &DBUserCoefficient);
        m_toolp->readGroupStr(subGroup, "DomainTypeStr", DomainTypeStr);

        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = this->strFromType(DomainTypeStr);//str转换为具体类型

        m_toolp->readGroupint(subGroup, "ID", &ID);
        m_toolp->readGroupint(subGroup, "FromType", &FromType);
        m_toolp->readGroupint(subGroup, "DBEnableState", &DBEnableState);
        m_toolp->readGroupint(subGroup, "AWeightingEnableState", &AWeightingEnableState);
        m_toolp->readGroupint(subGroup, "OctaveNum", &OctaveNum);


        Acoustics::FITKSpectraPower*newObjData = new Acoustics::FITKSpectraPower();
        if (newObjData==nullptr)
        {
            continue;
        }
        newObjData->init(StarFreq, EndFreq, Dtype);//需要先初始化，后进行赋值
        if (this->readBaseData(newObjData, thisMaterialsGroup, i) == false)//读取基类数据
        {
            return false;
        }

        newObjData->setFormCalcType(FromType);//设置form类型
        newObjData->setDBEnableState(DBEnableState == 1 ? true : false);
        newObjData->setAWeightingEnableState(AWeightingEnableState == 1 ? true : false);
        newObjData->setDBUserCoefficient(DBUserCoefficient);
        Core::FITKAbstractDataIDAlter a;
        a.modifyDataID(newObjData, ID);
        mager->appendDataObj(newObjData);
    }
    return true;
}


bool IO::FITKAcousticsSpectraMgrAdaptor::writeBaseData(H5::Group & SpectraGroup, QList<Acoustics::FITKAcousticsAbstractSpectra*> BaseData)
{

    for (int i = 0; i < BaseData.size(); ++i)
    {
        Acoustics::FITKAcousticsAbstractSpectra* ObjP = BaseData.at(i);
        if (ObjP == nullptr)
        {
            continue;
        }
        QString Name = ObjP->getDataObjectName();   //一行名称
        double StarFreq = ObjP->getStartFreq();     //开始频率
        double EndFreq = ObjP->getEndFreq();        //结束频率
        double BandWidth = ObjP->getBandWidth();    //带宽
        QString Describe = ObjP->getNotes();        //获取描述
        int ID = ObjP->getDataObjectID();           //获取数据ID
        QList<Acoustics::SpectraValue>SpectraValue = ObjP->getSpectraValue();//频谱数据

        std::vector<double>hzV;//频率
        std::vector<double>realV;//实部
        std::vector<double>ImaginaryV;//虚部
        this->getSpectraValueData(SpectraValue, hzV, realV, ImaginaryV);


        int OctaveNum = ObjP->getOctaveNum();
        Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype = ObjP->getDomainType();//频率类型
        std::string DomainTypeStr = this->getDomainTypeString(Dtype);//根据类型转为Str

        //检查字符串输入是否有特殊字符
        m_toolp->CheckString(Name);
        m_toolp->CheckString(Describe);

        //在组下创建具体材料属性,并绑定到组
        m_toolp->CreateNameFromAttr(SpectraGroup, i, Name.toStdString());

        std::tuple<bool, H5::Group>Ret = m_toolp->createGp(SpectraGroup, Name);//创建子节点
        if (std::get<0>(Ret) == false) { continue; }

        H5::Group subGroup = std::get<1>(Ret);

        std::vector<bool>writeResultBools;//存储此次写入时返回成功与否数据
        //将数据写入到具体属性中
        writeResultBools.push_back(m_toolp->writeGroupAttrStr(subGroup, "Name", Name.toStdString()));
        writeResultBools.push_back(m_toolp->writeGroupAttrDouble(subGroup, "StarFreq", StarFreq));
        writeResultBools.push_back(m_toolp->writeGroupAttrDouble(subGroup, "EndFreq", EndFreq));
        writeResultBools.push_back(m_toolp->writeGroupAttrDouble(subGroup, "BandWidth", BandWidth));
        writeResultBools.push_back(m_toolp->writeGroupAttrStr(subGroup, "Describe", Describe.toStdString()));
        writeResultBools.push_back(m_toolp->writeGroupAttrStr(subGroup, "DomainTypeStr", DomainTypeStr));
        writeResultBools.push_back(m_toolp->writeGroupAttrInt(subGroup, "ID", ID));
        writeResultBools.push_back(m_toolp->writeGroupAttrInt(subGroup, "OctaveNum", OctaveNum));
        writeResultBools.push_back(m_toolp->CreateOneDarrayDataSetDouble(subGroup, "hzV", hzV));
        writeResultBools.push_back(m_toolp->CreateOneDarrayDataSetDouble(subGroup, "realV", realV));
        writeResultBools.push_back(m_toolp->CreateOneDarrayDataSetDouble(subGroup, "ImaginaryV", ImaginaryV));
        bool allBool = this->areAllTrue(writeResultBools);
        if (allBool == false)
        {
            //如果不是全部都为true则，写入失败，写该数据终止
            return false;
        }
    }

    return true;
}


bool IO::FITKAcousticsSpectraMgrAdaptor::readBaseData(Acoustics::FITKAcousticsAbstractSpectra* newObjData, H5::Group thisGroup, int i)
{
    if (newObjData==nullptr)
    {
        return false;
    }
    //通过转换i为str，获取该str属性下对应组的名称(具体材料名称)
    std::string subGroupName = m_toolp->readGroupAttrName(thisGroup, i);
    //打开子组
    std::tuple<bool, H5::Group>RetGroup = m_toolp->openGp(thisGroup, subGroupName.data());
    if (std::get<0>(RetGroup) == false) { return false; }//打不开则退出此次
    H5::Group subGroup = std::get<1>(RetGroup);

    std::string Name = "";
    std::string Describe = "";

    std::vector<double>hzV{};//频率
    std::vector<double>realV{};//实部
    std::vector<double>ImaginaryV{};//虚部
    QList<Acoustics::SpectraValue>SpectraValue;

    Name = subGroupName;
    m_toolp->readGroupStr(subGroup, "Describe", Describe);
    m_toolp->ReadOneDArrayDataSetDouble(subGroup, "hzV", hzV);
    m_toolp->ReadOneDArrayDataSetDouble(subGroup, "realV", realV);
    m_toolp->ReadOneDArrayDataSetDouble(subGroup, "ImaginaryV", ImaginaryV);


    SpectraValue = this->MergeSpectraValue(hzV, realV, ImaginaryV);//合并频谱数据

    newObjData->setDataObjectName(RestoreStr(Name));
    newObjData->setNotes(RestoreStr(Describe));
    newObjData->setSpectraValue(SpectraValue);

    return true;
}

bool IO::FITKAcousticsSpectraMgrAdaptor::areAllTrue(const std::vector<bool>& Data)
{
    return std::all_of(Data.begin(), Data.end(), [](bool b) { return b; });
}

void IO::FITKAcousticsSpectraMgrAdaptor::getSpectraValueData(QList<Acoustics::SpectraValue>&SpectraValue, std::vector<double>& hzv, std::vector<double>& realV, std::vector<double>& ImaginaryV)
{
    for (auto &SpValue : SpectraValue)
    {
        hzv.push_back(SpValue._hz);//频率
        Core::FITKNumberComplex NumberComplex = SpValue._value;//复数
        realV.push_back(NumberComplex.getReal());//实部
        ImaginaryV.push_back(NumberComplex.getImaginary());//虚部
    }
}

QList<Acoustics::SpectraValue> IO::FITKAcousticsSpectraMgrAdaptor::MergeSpectraValue(std::vector<double>& hzV, std::vector<double>& realV, std::vector<double>& ImaginaryV)
{
    QList<Acoustics::SpectraValue>Ret;
    for (int i = 0; i < hzV.size(); ++i)
    {
        Acoustics::SpectraValue da;
        da._hz = hzV.at(i);
        Core::FITKNumberComplex cm;
        cm.setReal(realV.at(i));
        cm.setImaginary(ImaginaryV.at(i));
        da._value = cm;
        Ret.push_back(da);
    }


    return Ret;
}

std::string IO::FITKAcousticsSpectraMgrAdaptor::getDomainTypeString(Acoustics::FITKGlobalFrequencyDomain::DomainType Dtype)
{

    switch (Dtype)
    {
    case Acoustics::FITKGlobalFrequencyDomain::DTNone:
    {
        return "DTNone";
        break;
    }
    case Acoustics::FITKGlobalFrequencyDomain::DTStandardOctave:
    {
        return "DTStandardOctave";
        break;
    }
    case Acoustics::FITKGlobalFrequencyDomain::DTStandard1Of3rdOctave:
    {
        return "DTStandard1Of3rdOctave";
        break;
    }
    case Acoustics::FITKGlobalFrequencyDomain::DTExact1OfnthOctave:
    {
        return "DTExact1OfnthOctave";
        break;
    }
    case Acoustics::FITKGlobalFrequencyDomain::DTConstantBandWidth:
    {
        return "DTConstantBandWidth";
        break;
    }
    default:
        return {};
        break;
    }
}

Acoustics::FITKGlobalFrequencyDomain::DomainType IO::FITKAcousticsSpectraMgrAdaptor::strFromType(std::string Str)
{
    if (Str == "DTNone")
    {
        return Acoustics::FITKGlobalFrequencyDomain::DTStandardOctave;
    }
    if (Str == "DTStandardOctave")
    {
        return Acoustics::FITKGlobalFrequencyDomain::DTNone;
    }
    if (Str == "DTStandard1Of3rdOctave")
    {
        return Acoustics::FITKGlobalFrequencyDomain::DTStandard1Of3rdOctave;
    }
    if (Str == "DTExact1OfnthOctave")
    {
        return Acoustics::FITKGlobalFrequencyDomain::DTExact1OfnthOctave;
    }
    if (Str == "DTConstantBandWidth")
    {
        return Acoustics::FITKGlobalFrequencyDomain::DTConstantBandWidth;
    }
    return Acoustics::FITKGlobalFrequencyDomain::DomainType::DTNone;
}
